<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: categories_list.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$module_smarty = new smarty;
$module_content = '';

$module_smarty->assign('language', $_SESSION['language']);

if (!CacheCheck()) {
	$cache=false;
	$module_smarty->caching = false;
	
} else {
	$cache=true;
	$module_smarty->caching = true;
	$module_smarty->cache_lifetime = CACHE_LIFETIME;
	$module_smarty->cache_modified_check = CACHE_CHECK;
	$cache_id = $_SESSION['language'].$_SESSION['customers_status']['customers_status_id'].$cPath;
}

if(!$module_smarty->isCached(CURRENT_TEMPLATE.'/module/categories_list.html', $cache_id) || !$cache) {

	$module_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');

	if (GROUP_CHECK == 'true')
		$group_check = " c.group_permission_".$_SESSION['customers_status']['customers_status_id']." = 1 AND ";

	$categories = $db->db_query("SELECT
										c.categories_id,
										c.categories_image,
										cd.categories_name,
										cd.categories_description
									FROM
										".TABLE_CATEGORIES." AS c,
										".TABLE_CATEGORIES_DESCRIPTION." AS cd
									WHERE
										c.categories_id = cd.categories_id 
									AND
										c.parent_id = '0' 
									AND
										".$group_check." 
										c.categories_status = '1' 
									AND
										cd.language_id = '" .(int)$_SESSION['languages_id']. "'
									ORDER BY
											c.sort_order ASC");

		while(!$categories->EOF) {
			$image = '';
			$catname = '';
			$catdesc = '';
			
			if ($categories->fields['categories_image'] != '' && CATEGORY_LISTING_START_PICTURE == 'true') {
				$image = DIR_WS_IMAGES.'categories/'.$categories->fields['categories_image'];
				$imagessize = get_img_size($image);
			}
			
			if (CATEGORY_LISTING_START_HEAD == 'true')
				$catname = $categories->fields['categories_name'];
			
			if (CATEGORY_LISTING_START_DESCR == 'true')
				$catdesc = strip_tags($categories->fields['categories_description']);
		
			$category_link = category_link($categories->fields['categories_id']);
			$module_content[] = array ('CATEGORY_NAME' => $catname, 						   
									   'CATEGORY_IMAGE' => $image, 
									   'CATEGORY_IMAGE_DIMENSION' => $imagessize, 
									   'CATEGORY_LINK' => href_link(FILENAME_DEFAULT,  get_all_get_params(array(array('cat','page','filter_id','brand_id'))) . $category_link), 
									   'CATEGORY_DESCRIPTION' => $catdesc);
			$categories->MoveNext();
		}

	$module_smarty->assign('module_content', $module_content);
}

if (!$cache)
	$module_categories = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/categories_list.html');
else
	$module_categories = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/categories_list.html', $cache_id);

$default_smarty->assign('CATEGORIES_LIST', $module_categories);  
?>